package com.isyscore.mapper.admin;

import com.isyscore.entity.admin.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isyscore.model.sys.menu.query.MenuQueryReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单权限表 Mapper 接口
 * </p>
 *
 * @author LGL
 * @since 2024年10月25日
 */
@Mapper
public interface SysMenuMapper extends BaseMapper<SysMenu> {


    /**
     * 根据用户id获取菜单
     * @param userId
     * @return
     */
    @Select("select distinct m.* from sys_menu m left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_user_role ur on rm.role_id = ur.role_id where ur.user_id = #{userId} order by m.order_num")
    List<SysMenu> getMenusByUserId(Long userId);


    /**
     * 获取所有菜单
     * @param queryReq
     * @return
     */
    List<SysMenu> getAllMenus(MenuQueryReq queryReq);
}
